package com.ysstech.etfmanage.thread;

import java.util.concurrent.Callable;

import com.ysstech.etfmanage.entity.Account;
import com.ysstech.etfmanage.entity.ParamVo;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class EtfAccountThread implements Callable<Boolean> {
    private EtfAccountGenerateService etfAccountGenerateService;
    private ParamVo paramVo;
    private Account account;

    public EtfAccountThread(EtfAccountGenerateService etfAccountGenerateService, Account account, ParamVo paramVo) {
        this.etfAccountGenerateService = etfAccountGenerateService;
        this.paramVo = paramVo;
        this.account = account;
    }

    @Override
    public Boolean call() throws Exception {
        try {
            log.info("call()方法被自动调用，任务的结果是：" + account.getPurchaseDate()
                    + account.getAccountId() + "    " + Thread.currentThread().getName());
            etfAccountGenerateService.doGenerate(account, paramVo);
        } catch (Exception ex) {
            log.error(ex.toString());
            return false;
        }
        return true;
    }
}
